﻿
@{
    ViewBag.Title = "Config";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row" id="app">
    <div class="col-lg-12">
        <!--附加项-->
        <div class="row" id="fujiaxiangdiv">
            <div class="col-xs-12">
                <!--搜索-->
                <div class="row">
                    <div class="col-xs-12 col-sm-8">
                        <p>
                            <button class="btn btn-white btn-info btn-bold" v-on:click="P_AddNewPage">
                                <i class="ace-icon glyphicon glyphicon-plus bigger-120 blue"></i>
                                新附加项
                            </button>
                        </p>
                    </div>
                </div>
                <!--附加项列表-->
                <div class="row">
                    <div class="col-xs-12">
                        <table id="simple-table" class="table  table-bordered table-hover">
                            <thead>
                                <tr>

                                    <th>附加项</th>
                                    <th>分值</th>
                                    <th></th>
                                </tr>
                            </thead>

                            <tbody>
                                <tr v-for="item in fujiaxianglist">

                                    <td>{{item.fjxmc}}</td>
                                    <td>
                                        {{item.fjxfz}}
                                    </td>
                                    <td>
                                        <div class="btn-group">
                                            <button data-toggle="dropdown" class="btn btn-primary btn-white dropdown-toggle btn-sm " aria-expanded="true">
                                                操作
                                                <i class="ace-icon fa fa-angle-down icon-on-right"></i>
                                            </button>

                                            <ul class="dropdown-menu">
                                                <li>
                                                    <a href="javascript:void(0)" v-on:click="p_EditData(item)">编辑</a>
                                                </li>

                                                <li>
                                                    <a href="javascript:void(0)" v-on:click="p_DelData(item.fjxid)">删除</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>

                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <!--弹出框-->
        <div class="row">
            <div class="col-xs-12">
                <div id="dialog-message" class="hide">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="form-horizontal" role="form">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 附加项名称 </label>
                                    <div class="col-sm-9"><input type="text" placeholder="附加项名称" class="col-xs-12" v-model="fujiaxianginfo.fjxmc" /></div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 附加项分值 </label>
                                    <div class="col-sm-9"><input type="text" placeholder="附加项分值" class="col-xs-10 col-sm-5" v-model="fujiaxianginfo.fjxfz" /></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- #dialog-message -->
            </div>
        </div>
        @*<div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 加分项 </label>
            <div class="col-sm-9">
                <select class="form-control" v-model="fujiaxianginfo.fjxid">
                    <option value="0">未选择</option>
                    <option v-for="option in fujiaxianglist" v-bind:value="option.fjxid"> {{ option.fjxmc }}</option>
                </select>
            </div>
        </div>*@
    </div>
</div>
<script src="~/Scripts/JsModel/Model_FuJiaXiang.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: "#app",
        data: {
            fujiaxianglist: [],
            fujiaxianginfo: new FuJiaXiang()
        },
        mounted() {
            this.init();
        },
        methods: {
            init: function() {
                var _self = this;
                _self.p_GetFuJiaXiangs();
            },
            p_GetFuJiaXiangs: function() {
                var _self = this;
                //获取工作计划
                axios.get("@Url.Action("GetFuJiaXiangs", "FuJiaXiang")").then((response) => {
                    _self.fujiaxianglist = [];
                        for (var i = 0; i < response.data.length; i++) {
                            _self.fujiaxianglist.push(new FuJiaXiang(response.data[i]));
                        }
                    },
                    (response) => {

                    }
                ).catch(function(response) {
                    console.log(response);
                });
            },
            p_SaveFuJiaXiang: function () {
                var _self = this;
                axios.post("@Url.Action("AddFuJiaXiang", "FuJiaXiang")", _self.fujiaxianginfo).then((response) => {
                        bootbox.alert("成功", function() {
                            _self.p_GetFuJiaXiangs();
                        });
                    },
                    (response) => {

                    }
                ).catch(function(response) {
                    console.log(response);
                });
            },
            p_DelData: function(fjxid) {
                var _self = this;
                bootbox.confirm("你确定这个操作吗?",
                    function(result) {
                        if (result) {
                            axios.get('@Url.Action("DelFuJiaXiang", "FuJiaXiang")', { params: { fjxid: fjxid } }).then(
                                    function (response) {
                                        bootbox.alert("成功", function() {
                                            _self.p_GetFuJiaXiangs();
                                        });
                                    },
                                    function(response) {
                                        alert(response.status);
                                    }
                                )
                                .catch(
                                    function(error) {
                                        alert(error);
                                    }
                                );
                        }
                    });

            },
            P_AddNewPage: function (e) {//弹出新增科室窗口
                var _self = this;
                e.preventDefault();
                var dialog = dialog_comm(true,"dialog-message", "新增附加项信息", null, function () { _self.p_SaveFuJiaXiang(); },true,600);
            }
        }
    });
</script>